<?php


namespace app\api\model\operation;


use app\logic\model\activity\ActivityCommonModel;

class ActivityModel extends ActivityCommonModel
{
    function getActivityStartTimeAttr($val){
        $str='';
        if(!empty($val)) {
            $str = date('Y-m-d H:i:s', $val);
        }
        return array(
            'str'=>$str,
            'val'=>$val,
        );
    }
    function getActivityEndTimeAttr($val){
        $str='';
        if(!empty($val)) {
            $str = date('Y-m-d H:i:s', $val);
        }
        return array(
            'str'=>$str,
            'val'=>$val,
        );
    }
    function getBuyStartTimeAttr($val){
        $str='';
        if(!empty($val)) {
            $str = date('Y-m-d H:i:s', $val);
        }
        return array(
            'str'=>$str,
            'val'=>$val,
        );
    }
    function getBuyEndTimeAttr($val){
        $str='';
        if(!empty($val)) {
            $str = date('Y-m-d H:i:s', $val);
        }
        return array(
            'str'=>$str,
            'val'=>$val,
        );
    }
    function getList($field,$limit){
        $list=$this
            ->where('status','<',2)
            ->where('is_del',0)
            ->where("is_open",1)
            ->where('activity_end_time','>=',time())
            ->field($field)
            ->paginate($limit);
        if(!$list->isEmpty()){
            return $list->toArray();
        }
        return $list;
    }
}